home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2005 October / PCWOCT05.iso / Software / FromTheMag / Ant Movie Catalog 3.5.0.2 / amc_install.exe / {app} / Scripts / dvd-bonus.ifs < prev    next >
Text File  |  2005-03-13  |  4KB  |  120 lines

  1. (***************************************************
  2.  
  3. Ant Movie Catalog importation script
  4. www.antp.be/software/moviecatalog/
  5.  
  6. [Infos]
  7. Authors=Johan Venant
  8. Title=dvd-bonus(Menus cachΘs)
  9. Description=Ajoute des informations concernant l'accΦs aux menus cachΘs dans les commentaires
  10. Site=www.dvd-bonus.com
  11. Language=FR
  12. Version=0.3 (28 Jan 2005)
  13. Requires=3.5.0
  14. Comments=Pas encore parfait mais bon, quand ca marche... ca marche! ;).|Le moteur de recherche semble avoir du mal avec les titres compliquΘs (":", "-",...)
  15. License=This program is free software; you can redistribute it and/or modify it under the  terms of the GNU General Public License as published by the Free Software Foundation;  either version 2 of the License, or (at your option) any later version. |
  16. GetInfo=1
  17.  
  18. [Options]
  19. Appends=1|1|0=Remplace les commentaires existant|1=S'ajoute aux commentaires existant
  20.  
  21. ***************************************************)
  22.  
  23. program dvdworld;
  24.  
  25. uses
  26.     StringUtils7552;
  27.  
  28. const
  29.     baseUrl = 'http://www.dvd-bonus.com/';
  30.     searchUrl = baseUrl + 'moteur/recherche.php';
  31.     startStr = 'resultat_fiche.php?ID=';
  32.     endStr = '&type=Bonus cachΘs"';
  33.     dataStrStart = '<strong><span class="paragraphenoir">Comment faire ?</span></strong><br>';
  34.     dataStrEnd = '</span>';
  35.     separatorStart = CRLF+CRLF+CRLF+ '--------------------------------Bonus cachΘs--------------------------------' + CRLF;
  36.     separatorEnd =   CRLF + '----------------------------------------------------------------------------' + CRLF;
  37. var
  38.     MovieName: string;
  39. Function FindBefore(wordToFind: string; text: string; sPos: Integer):Integer;
  40. var
  41.     iPos, iFound: Integer;
  42. begin
  43.     Text:= Copy(Text, 1, sPos);
  44.     iPos:= Pos(wordToFind, Text);
  45.     iFound:= iPos;
  46.     while iPos > 0 do
  47.     begin
  48.       Delete(Text, 1, iPos);
  49.       iPos:= Pos(wordToFind, Text);
  50.       iFound:= iFound + iPos;
  51.     end;
  52.     result:= iFound;
  53. end;
  54. Procedure searchMovie(title : string);
  55. var
  56.     page,params,address,nodeName: string;
  57.     adrStart,adrEnd: Integer;
  58.     found: Boolean;
  59. begin
  60.     PickTreeClear;
  61.     found := False;
  62.     params := 'mot='+title+'&operateur=et';
  63.     PickTreeAdd('RΘsultats de la recherche de "' + title + '"', '');
  64.     page := PostPage(searchUrl,URLEncode(params));
  65.     adrEnd := Pos(endStr, page) ;
  66.     while adrEnd > 0 do
  67.     begin
  68.       found := True;
  69.       adrStart := FindBefore( '<a href="../'+startStr,page,adrEnd + Length(endStr))+Length('<a href="../')-1;
  70.       Delete(page, 1, adrStart);
  71.       address := TextBefore(page,'">','');
  72.       Delete(page, 1, Pos('">',page)+1);
  73.       nodeName := TextBefore(page,'</a>','');
  74.       HTMLRemoveTags(nodeName);
  75.       PickTreeAdd(nodeName,address);
  76.       Delete(page, 1, Pos('</a>',page)+1);
  77.       adrEnd := Pos(endStr, page);
  78.     end;
  79.     if found then
  80.     begin
  81.       if PickTreeExec(address)then
  82.         retreiveData(address);
  83.     end
  84.     else
  85.       ShowInformation('Aucun film trouvΘ pour "' + MovieName + '"');
  86. end;
  87. Procedure retreiveData(address : string);
  88. var
  89.     page,data,curComments: string;
  90.     dataStart,dataEnd : Integer;
  91. begin
  92.     page := GetPage(URLEncode(baseUrl+address));
  93.     dataStart := Pos(dataStrStart, page) + Length(dataStrStart);
  94.     Delete(page,1,dataStart );
  95.     data := TextBefore(page,dataStrEnd,'');
  96.     data := StringReplace(data, #9, '');
  97.     data := StringReplace(data, #10, '');
  98.     data := StringReplace(data, #13, '');
  99.     data := StringReplace(data, '<br>', CRLF);
  100.     HTMLRemoveTags(data);
  101.     data := Trim(data);
  102.     if GetOption('Appends') = 1 then
  103.       SetField(fieldComments, GetField(fieldComments) +  separatorStart + data + separatorEnd)
  104.     else
  105.       SetField(fieldComments, data);
  106. end;
  107.  
  108. begin
  109.     if CheckVersion(3,5,0) then
  110.     begin
  111.       MovieName := GetField(fieldTranslatedTitle);
  112.       if MovieName = '' then
  113.         MovieName := GetField(fieldOriginalTitle);
  114.       if Input('Importation DVDFR', 'Entrez le titre du film :', MovieName) then
  115.         searchMovie(MovieName);
  116.     end
  117.     else
  118.       ShowError('Ce script requiert une version plus rΘcente de Ant Movie Catalog (au moins la version 3.5)');
  119. end.
  120.